{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## czsc 快速入门教程\n",
    "---\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys\n",
    "sys.path.insert(0, \".\")\n",
    "sys.path.insert(0, \"..\")\n",
    "\n",
    "import czsc\n",
    "print(czsc.__version__)\n",
    "assert czsc.__version__ >= \"0.6.1\"\n",
    "\n",
    "from czsc.analyze import CZSC\n",
    "from czsc.trader import CzscTrader\n",
    "from datetime import datetime\n",
    "\n",
    "# 如果需要实盘行情，导入聚宽数据\n",
    "from czsc.data.jq import *\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 首次使用需要设置聚宽账户\n",
    "# set_token(\"phone number\", 'password') # 第一个参数是JQData的手机号，第二个参数是登录密码\n",
    "\n",
    "print(\"聚宽剩余调用次数：{}\".format(get_query_count()))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##  `CzscTrader` 的使用案例\n",
    "---"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "ct = CzscTrader(symbol=\"300803.XSHE\", max_count=1000, end_date=datetime.now())\n",
    "# max_count 参数控制获取的K线数量\n",
    "# end_date  参数控制获取K线的截止时间，便于查看历史分析结果，默认为当下时间"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 可视化分析结果\n",
    "chart = ct.kf.take_snapshot(width=\"900px\", height=\"480px\")\n",
    "chart.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 调用选股方法判断是否有满足的选股条件\n",
    "ct.run_selector()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
